//	CP2013 Traffic Simulator Assignment
//      Traffic Model Vehicle
//	Java version
//      Coded by Matthew Johnson


package traffic;

import java.awt.Color;
import java.util.Random;

//A Vehicle on the Road in the Model
public class Vehicle {
    //The Vehicle's current position
    private Coordinate position;
    //The Vehicle's current direction
    private Direction direction;
    //The number of squares the vehicle moves per cycle
    private int speed;
    //The vehicle's length
    private int length;
    //The Vehicle's color
    private Color colour;



    //Pick a Random Color for the Car from 9 Posibilities
    public void pickRandColour()
    {
        //Picked based on a Random number from 0 - 8
        switch (new Random().nextInt(9))
        {
            case 0:
                colour = Color.red;
                break;
            case 1:
                colour = Color.orange;
                break;
            case 2:
                colour = Color.yellow;
                break;
            case 3:
                colour = Color.green;
                break;
            case 4:
                colour = Color.blue;
                break;
            case 5:
                colour = Color.MAGENTA;
                break;
            case 6:
                colour = Color.PINK;
                break;
            case 7:
                colour = Color.CYAN;
                break;
            case 8:
                colour = Color.WHITE;
                break;
        }
    }

    //Constructor: Sets up Vehicle with set position, direction and length and a random colour
    Vehicle (int x, int y, Direction dir, int len){
        position = new Coordinate(x,y);
        direction = dir;
        length = len;
        speed = 1;
        pickRandColour();
    }

    //Constructor: Sets up Vehicle with set position, direction and length and a random colour
    Vehicle (Coordinate c, Direction dir, int len){
        position = c;
        direction = dir;
        length = len;
        speed = 1;
        pickRandColour();
    }

    //Getters and Setters
    public Direction getDirection()
    {
        return direction;
    }

    public void setDirection(Direction direction)
    {
        this.direction = direction;
    }

    public Coordinate getPosition()
    {
        return position;
    }

    public void setPosition(Coordinate position)
    {
        this.position = position;
    }

    public int getSpeed()
    {
        return speed;
    }

    public void setSpeed(int speed)
    {
        this.speed = speed;
    }

    public int getLength()
    {
        return length;
    }

    public Color getColour()
    {
        return colour;
    }

    public void setLength(int length)
    {
        this.length = length;
    }
}
